// pages/auditList/auditList.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    showName: '',
    prolist: [],
    // 搜索
    serach_pro: "",
    isUpdate: false,
    bankId: '',
    pageNum: 1,
    prosum: '',
    userInfo: ''
  },
  goList () {
    this.setData({
      isUpdate: false,
    })
    wx.navigateTo({
      url: '../../../packageA/pages/bankAuditList/bankAuditList'
    })
  },
  goDetail (e) {
    this.setData({
      isUpdate: false
    })
    console.log(e.currentTarget.dataset.item)
    const itemObj = JSON.stringify(e.currentTarget.dataset.item)
    wx.navigateTo({
      url: `../../../packageB/pages/userManagement/userManagement?itemObj=${itemObj}`
    })
  },
  goSearch () {
    console.log('进行搜索')
    this.setData({
      pageNum: 1,
      prolist: [],
      prosum: ''
    })
    this.getList();
  },
  goOnChange (e) {
    this.setData({
      serach_pro: e.detail,
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad () {
    const userInfo = wx.getStorageSync('userInfo')
    this.setData({
      userInfo: userInfo
    })
    this.getList()
  },
  getList () {
    let _this = this;
    this.setData({
      loading: true,
    })
    wx.showLoading({
      title: "加载中",
    });
    const params = {
      pageSize: 25,
      pageNum: this.data.pageNum,
      bankId: this.data.bankId,
      searchParam: this.data.serach_pro
    }
    if (!this.data.bankId) {
      delete params.bankId
    }
    console.log(params, 'params'),
      getApp()
        .globalData.request("/visit/getAccountManagersByBankId", params, "POST")
        .then((res) => {
          setTimeout(function () {
            wx.hideLoading();
          }, 500);
          let rstObj = res;
          console.log(res, "res");
          if (rstObj.data) {
            _this.setData({
              prolist: this.data.prolist.concat(rstObj.data.list),
              prosum: rstObj.data.total,
            });
            this.setData({
              loading: false,
            })
          }
        });
  },
  scrollBottom () {
    this.onBottom()
  },
  onBottom () {
    if (this.data.prolist.length >= this.data.prosum) return
    this.data.pageNum++;
    this.getList();
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady () {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow () {
    console.log(this.data.isUpdate, 'this.data.isUpdate')
    // if (this.data.name !== this.data.form.form_bank) {
    //   this.setData({
    //     ["form.form_bank"]: this.data.name,
    //     ["form.form_bank1"]: '',
    //   })
    // } else {
    //   this.setData({
    //     ["form.form_bank"]: this.data.name,
    //     ["form.form_bank1"]: this.data.branchName
    //   })
    // }
    if (this.data.isUpdate) {
      this.setData({
        pageNum: 1,
        prolist: [],
        prosum: ''
      })
      this.getList();
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage () {

  }
})